package com.songlanyun.modules.distributionconfig.controller.admin;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.songlanyun.common.annotation.SysLog;
import com.songlanyun.modules.distributionconfig.model.DistributionShopGoodsConfigDTO;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.songlanyun.modules.distributionconfig.entity.DistributionShopGoodsConfig;
import com.songlanyun.modules.distributionconfig.service.DistributionShopGoodsConfigService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;



/**
 * 商家商品级分销设置
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-12-22 11:43:24
 */
@RestController
@RequestMapping("admin/distribution/goodsconfig")
public class DistributionShopGoodsConfigAdminController extends AbstractController {
    @Autowired
    private DistributionShopGoodsConfigService distributionShopGoodsConfigService;


    /**
     * 查看商家商品级分销设置信息
     */
    @RequestMapping("/info/{goodsId}")
    //@RequiresPermissions("distributionconfig:distributionshopgoodsconfig:info")
    public R info(@PathVariable("goodsId") Long goodsId){
		DistributionShopGoodsConfig distributionShopGoodsConfig = distributionShopGoodsConfigService.getShopAndGoods(getShopId(true),goodsId);
        return R.ok().put("data", distributionShopGoodsConfig);
    }

    /**
     * 保存家商品级分销设置
     */
    @SysLog("保存家商品级分销设置")
    @RequestMapping("/set")
    //@RequiresPermissions("distributionconfig:distributionshopgoodsconfig:save")
    public R save(@RequestBody DistributionShopGoodsConfigDTO dto){
        DistributionShopGoodsConfig distributionShopGoodsConfig = distributionShopGoodsConfigService.set(getShopId(true),dto);
        return R.ok().put("data", distributionShopGoodsConfig);
    }


}
